* Cult of Personality Data Processing

cap cd "~/data"

**** China Analysis**** 
use china_news, replace

gen leader_total= leader_mention+leader_propaganda
gen other_total= other_mention+other_propaganda
gen leader_propaganda2= leader_propaganda
gen other_propaganda2= other_propaganda


drop if date==.
gen count=1
egen issues = sum(count), by(year)
egen sum_prop_leader = sum(leader_propaganda), by(year)
egen sum_prop_other = sum(other_propaganda), by(year)
egen sum_mention_leader = sum(leader_mention), by(year)
egen sum_mention_other = sum(other_mention), by(year)
gen avg_prop_leader=sum_prop_leader/issues
gen avg_prop_other=sum_prop_other/issues
gen avg_mention_leader=sum_mention_leader/issues
gen avg_mention_other=sum_mention_other/issues

collapse avg_prop_leader avg_prop_other  avg_mention_leader avg_mention_other (sum) leader_propaganda2 (sum) other_propaganda2, by(year)

twoway    (line avg_prop_leader year , cmiss(n) lcolor(gs1) lwidth(medthick))   (line avg_prop_other year ,lwidth(medthick) cmiss(n) lpattern(dash) xlabel(1937(3)1976, angle(45)) lcolor(gs7) xline(1949) plotregion(fcolor(white)) plotregion(ifcolor(white)) xtitle("")  ytitle("Average Mentions Per Issue") legend(lab(1 "Mao Symbolic Mentions") lab(2 "Other Symbolic Mentions") region(col(white) lcolor(black) lpattern(solid)) pos(2) row(2) ring(0)))   
 
twoway    (line avg_prop_leader year , cmiss(n) lcolor(gs1) lwidth(medthick))   (line avg_mention_leader year ,lwidth(medthick) cmiss(n) lpattern(dash) xlabel(1937(3)1976, angle(45)) lcolor(gs7) xline(1949) plotregion(fcolor(white)) plotregion(ifcolor(white)) xtitle("")  ytitle("Average Mentions Per Issue") legend(lab(1 "Mao Symbolic Mentions") lab(2 "Mao Ordinary Mentions") region(col(white) lcolor(black) lpattern(solid)) pos(2) row(2) ring(0)))   


****** Vietnam Analysis ****** 
* Cult of Personality Data Processing

use vietnam_news, replace
keep date-other_propaganda

drop if date==.
gen count=1
egen issues = sum(count), by(year)
egen sum_prop_leader = sum(leader_propaganda), by(year)
egen sum_prop_other = sum(other_propaganda), by(year)
egen sum_mention_leader = sum(leader_mention), by(year)
egen sum_mention_other = sum(other_mention), by(year)
gen avg_prop_leader=sum_prop_leader/issues
gen avg_prop_other=sum_prop_other/issues
gen avg_mention_leader=sum_mention_leader/issues
gen avg_mention_other=sum_mention_other/issues

collapse avg_prop_leader avg_prop_other  avg_mention_leader avg_mention_other , by(year)
drop if year>1969

gen missing=0
insobs 1
replace year=1948 if year==.
insobs 1
replace year=1949 if year==.
insobs 1
replace year=1956 if year==.
insobs 1
replace year=1967 if year==.
replace missing =1 if avg_prop_leader==.

sort year 

twoway    (line avg_prop_leader year , cmiss(n) lcolor(gs1) lwidth(medthick))   (line avg_prop_other year ,lwidth(medthick) cmiss(n) lpattern(dash) xlabel(1945(1)1966, angle(45)) lcolor(gs7) xline(1954) plotregion(fcolor(white)) plotregion(ifcolor(white)) xtitle("")  ytitle("Average Mentions Per Issue") legend(lab(1 "HCM Symbolic Mentions") lab(2 "Other Symbolic Mentions") region(col(white) lcolor(black) lpattern(solid)) pos(2) row(2) ring(0)))  

twoway    (line avg_prop_leader year , cmiss(n) lcolor(gs1) lwidth(medthick))   (line avg_mention_leader year ,lwidth(medthick) cmiss(n) lpattern(dash) xlabel(1945(1)1966, angle(45)) lcolor(gs7) xline(1954) plotregion(fcolor(white)) plotregion(ifcolor(white)) xtitle("")  ytitle("Average Mentions Per Issue") legend(lab(1 "HCM Symbolic Mentions") lab(2 "HCM Ordinary Mentions") region(col(white) lcolor(black) lpattern(solid)) pos(2) row(2) ring(0)))  

**** Indonesia Analysis**** 
use indo_news, replace

sort country date

drop if date==.
gen count=1
egen issues = sum(count), by(year)
egen sum_prop_leader = sum(leader_propaganda), by(year)
egen sum_prop_other = sum(other_propaganda), by(year)

egen sum_mention_leader = sum(leader_mention), by(year)
egen sum_mention_other = sum(other_mention), by(year)

gen avg_prop_leader=sum_prop_leader/issues
gen avg_prop_other=sum_prop_other/issues

gen avg_mention_leader=sum_mention_leader/issues
gen avg_mention_other=sum_mention_other/issues

collapse avg_prop_leader avg_prop_other   avg_mention_leader avg_mention_other, by(year)

gen missing=0
insobs 1
replace year=1952 if year==.
insobs 1
replace year=1953 if year==.
drop if year>1963
replace missing =1 if avg_prop_leader==.
sort year

twoway    (line avg_prop_leader year , cmiss(n) lcolor(gs1) lwidth(medthick))   (line avg_prop_other year ,lwidth(medthick) cmiss(n) lpattern(dash) xlabel(1945(1)1963, angle(45)) lcolor(gs7) xline(1950) plotregion(fcolor(white)) plotregion(ifcolor(white)) xtitle("")  ytitle("Average Mentions Per Issue") legend(lab(1 "Sukarno Symbolic Mentions") lab(2 "Other Symbolic Mentions") region(col(white) lcolor(black) lpattern(solid)) pos(2) row(2) ring(0)))   

twoway    (line avg_prop_leader year , cmiss(n) lcolor(gs1) lwidth(medthick))   (line avg_mention_leader year ,lwidth(medthick) cmiss(n) lpattern(dash) xlabel(1945(1)1963, angle(45)) lcolor(gs7) xline(1950) plotregion(fcolor(white)) plotregion(ifcolor(white)) xtitle("")  ytitle("Average Mentions Per Issue") legend(lab(1 "Sukarno Symbolic Mentions") lab(2 "Sukarno Ordinary Mentions") region(col(white) lcolor(black) lpattern(solid)) pos(2) row(2) ring(0)))   
